home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Zope.exe / GFTEST.PY < prev    next >
Encoding:
Python Source  |  1999-07-28  |  20.8 KB  |  724 lines

  1. """test script for gadfly
  2.  
  3. usage gftest.py <directory>
  4.  
  5. run in current directory creates a database in files
  6.   test.dfs LIKES.grl SERVES.grl FREQUENTS.grl
  7. """
  8.  
  9. def test(directory):
  10.     print "testing"
  11.     from gadfly import gadfly
  12.     connect = gadfly()
  13.     connect.startup("test", directory)
  14.     curs = connect.cursor()
  15.     print
  16.     print "TABLE CREATES"
  17.     for x in table_creates:
  18.         print x
  19.         curs.execute(x)
  20.     curs.execute("create table empty (nothing varchar)")
  21.     C = """
  22.     CREATE TABLE work (
  23.        name VARCHAR,
  24.        hours INTEGER,
  25.        rate FLOAT)
  26.        """
  27.     print C
  28.     curs.execute(C)
  29.     print
  30.     C = """
  31.     CREATE TABLE accesses (
  32.        page VARCHAR,
  33.        hits INTEGER,
  34.        month INTEGER)
  35.        """
  36.     print C
  37.     curs.execute(C)
  38.     print
  39.     print "INSERTS"
  40.     C = """
  41.     INSERT INTO work(name, hours, rate) VALUES (?, ?, ?)
  42.     """
  43.     D = [
  44.          ("sam", 30, 40.2),
  45.          ("norm", 45, 10.2),
  46.          ("woody", 80, 5.4),
  47.          ("diane", 3, 4.4),
  48.          ("rebecca", 120, 12.9),
  49.          ("cliff", 26, 200.00),
  50.          ("carla", 9, 3.5),
  51.          ]
  52.     for x in D: print x
  53.     curs.execute(C, D)
  54.     C = "create unique index wname on work(name)"
  55.     print "Unique index:", C
  56.     curs.execute(C)
  57.     print "trying bad insert into unique field"
  58.     C = "insert into work(name, hours, rate) values ('sam', 0, 0)"
  59.     import sys
  60.     try:
  61.         curs.execute(C)
  62.     except:
  63.         print "exception as expected %s(%s)" %(sys.exc_type, sys.exc_value)
  64.     else:
  65.         raise "stop!", "unique index permits nonunique field"
  66.     print; print "testing introspection"
  67.     itests = ["select 10*4 from dual",
  68.               "select * from __table_names__",
  69.               #"select * from __datadefs__", # needs formatting
  70.               "select * from __indices__",
  71.               "select * from __columns__",
  72.               "select * from __indexcols__",
  73.               """
  74.               select i.index_name, is_unique, table_name, column_name
  75.               from __indexcols__ c, __indices__ i
  76.               where c.index_name = i.index_name""",
  77.               ]
  78.     for C in itests:
  79.         print C
  80.         print
  81.         curs.execute(C)
  82.         print curs.pp()
  83.         print
  84.     print "testing complex, neg literals in insert"
  85.     curs.execute("insert into work(name, hours, rate) values ('jo', -1, 3.1e-44-1e26j)")
  86.     curs.execute("select * from work")
  87.     print curs.pp()
  88.     print "deleting jo"; print
  89.     curs.execute("delete from work where name='jo'")
  90.     C = """
  91.     INSERT INTO accesses(page, month, hits) VALUES (?, ?, ?)
  92.     """
  93.     D = [
  94.          ("index.html", 1, 2100),
  95.          ("index.html", 2, 3300),
  96.          ("index.html", 3, 1950),    
  97.          ("products.html", 1, 15),   
  98.          ("products.html", 2, 650),   
  99.          ("products.html", 3, 98),   
  100.          ("people.html", 1, 439),
  101.          ("people.html", 2, 12),
  102.          ("people.html", 3, 665),
  103.          ]
  104.     for x in D: print x
  105.     curs.execute(C, D)
  106.     for (table, stuff) in dpairs:
  107.         ins = "insert into %s values (?, ?, ?)" % table
  108.         if table!="frequents":
  109.            for parameters in dataseq(stuff):
  110.                print "singleinsert", table, parameters
  111.                curs.execute(ins, parameters)
  112.         else:
  113.            print
  114.            print "multiinsert", table
  115.            parameters = dataseq(stuff)
  116.            for p in parameters:
  117.                print p
  118.            print "multiinsert..."
  119.            curs.execute(ins, parameters)
  120.            print;print
  121.     print
  122.     print "INDICES"
  123.     for ci in indices:
  124.         print ci
  125.         curs.execute(ci)
  126.     print
  127.     print "QUERIES"
  128.     for x in workqueries:
  129.         print;print
  130.         print x
  131.         curs.execute(x)
  132.         print curs.pp()
  133.         
  134.     statement = """select name, hours
  135.                    from work"""
  136.     curs.execute(statement)
  137.     print "Hours worked this week"
  138.     print
  139.     for (name,hours) in curs.fetchall():
  140.         print "worker", name, "worked", hours, "hours"
  141.     print
  142.     print "end of work report"
  143.  
  144.     #return
  145.     for x in queries:
  146.         print; print
  147.         print x
  148.         curs.execute(x)
  149.         #for x in curs.commands:
  150.         #    print x
  151.         all = curs.fetchall()
  152.         if not all:
  153.            print "empty!"
  154.         else:
  155.            print curs.pp()
  156.            #for t in all:
  157.                #print t
  158.     #return
  159.     print
  160.     print "DYNAMIC QUERIES"
  161.     for (x,y) in dynamic_queries:
  162.         print; print
  163.         print x
  164.         print "dynamic=", y
  165.         curs.execute(x, y)
  166.         #for x in curs.commands:
  167.         #    print x
  168.         all = curs.fetchall()
  169.         if not all:
  170.            print "empty!"
  171.         else:
  172.            for t in all:
  173.                print t
  174.     print "repeat test"
  175.     from time import time
  176.     for x in repeats:
  177.         print "repeating", x
  178.         now = time()
  179.         curs.execute(x)
  180.         print time()-now, "first time"
  181.         now = time()
  182.         curs.execute(x)
  183.         print time()-now, "second time"
  184.         now = time()
  185.         curs.execute(x)
  186.         print time()-now, "third time"
  187.     print "*** committing work"
  188.     connect.commit()
  189.     connect.close()
  190.     print; print
  191.     return connect
  192.     
  193. table_creates = [
  194.  "create table frequents (drinker varchar, bar varchar, perweek integer)",
  195.  "create table likes (drinker varchar, beer varchar, perday integer)",
  196.  "create table serves (bar varchar, beer varchar, quantity integer)",
  197.  """Create view nondrinkers(d, b)
  198.     as select drinker, bar
  199.        from frequents
  200.        where drinker not in
  201.          (select drinker from likes)""",
  202.  ]
  203.  
  204. fdata = """\
  205.   adam    lolas        1
  206.   woody    cheers    5
  207.   sam        cheers    5
  208.   norm    cheers    3
  209.   wilt    joes        2
  210.   norm    joes        1
  211.   lola    lolas        6
  212.   norm    lolas        2
  213.   woody    lolas        1
  214.   pierre    frankies    0"""
  215.   
  216. sdata = """\
  217.   cheers    bud        500
  218.   cheers    samaddams    255
  219.   joes    bud        217
  220.   joes    samaddams    13
  221.   joes    mickies    2222
  222.   lolas    mickies    1515
  223.   lolas    pabst        333
  224.   winkos    rollingrock    432
  225.   frankies    snafu       5"""
  226.   
  227. ldata = """\
  228.   adam    bud            2
  229.   wilt    rollingrock        1
  230.   sam        bud            2
  231.   norm    rollingrock        3
  232.   norm    bud            2
  233.   nan        sierranevada    1    
  234.   woody    pabst            2
  235.   lola    mickies        5"""
  236.   
  237. dpairs = [
  238.    ("frequents", fdata),
  239.    ("serves", sdata),
  240.    ("likes", ldata),
  241.   ]
  242.   
  243. def dataseq(s):
  244.     from string import split
  245.     l = split(s, "\n")
  246.     result = map(split, l)
  247.     from string import atoi
  248.     for l in result:
  249.         l[2] = atoi(l[2])
  250.     result = map(tuple, result)
  251.     return result
  252.     
  253. indices = [
  254. """create index fd on frequents (drinker)""",
  255. """create index sbb on serves (beer, bar)""",
  256. """create index lb on likes (beer)""",
  257. """create index fb on frequents (bar)""",
  258. ]
  259.  
  260. repeats = [
  261. """-- drinkers bars and beers
  262.    -- where the drinker likes the beer
  263.    -- the bar serves the beer
  264.    -- and the drinker frequents the bar
  265.    select f.drinker, l.beer, s.bar
  266.    from frequents f, serves s, likes l
  267.    where f.drinker=l.drinker and s.bar=f.bar and s.beer=l.beer""",
  268. """select *
  269.    from frequents as f, serves as s
  270.    where f.bar = s.bar and
  271.      not exists(
  272.        select l.drinker, l.beer
  273.        from likes l
  274.        where l.drinker=f.drinker and s.beer=l.beer)""",
  275. """select * from frequents
  276.    where drinker = 'norm'""",
  277. ]
  278.  
  279. workqueries = [
  280. """-- everything from work
  281.    select * from work""",
  282. # stupid tests
  283. """select median(hours)
  284.    from work""",
  285. """select *
  286.    from work
  287.    where name='carla' -- just carla""",
  288. """select name, ' ain''t worth ', rate
  289.    from work -- the works table has more columns
  290.    where name='carla'""",
  291. """select name, -- name of worker
  292.           hours -- hours worked
  293.    from work""",
  294. """select name, hours*rate as pay
  295.    from work
  296.    order by name""",
  297. """select name, rate
  298.    from work
  299.    where rate>=20 and rate<=100""",
  300. """select name, rate
  301.    from work
  302.    where rate between 20 and 100""",
  303. """select name, rate
  304.    from work
  305.    where rate not between 20 and 100""",
  306. """select name, rate, hours, hours*rate as pay
  307.    from work""",
  308. """select name, rate, hours, hours*rate as pay
  309.    from work
  310.    where hours*rate>500 and (rate<100 or hours>5)""",
  311. """select name, rate, hours, hours*rate as pay
  312.    from work
  313.    where hours*rate>500 and rate<100 or hours>5""",
  314. """select avg(rate), min(hours), max(hours), sum(hours*rate) as expenses
  315.    from work""",
  316. """select * from accesses""",
  317. """select month, sum(hits) as totalhits
  318.    from accesses
  319.    where month<>1
  320.    group by month
  321.    order by 2""",
  322. """select month, sum(hits) as totalhits
  323.    from accesses
  324.    group by month
  325.    order by 2 desc""",
  326. """select month, sum(hits) as totalhits
  327.    from accesses
  328.    group by month
  329.    having sum(hits)<3000
  330.    order by 2 desc""",
  331. """select count(distinct month), count(distinct page)
  332.    from accesses""",
  333. """select month, hits, page
  334.    from  accesses
  335.    order by month, hits desc""",
  336. ]
  337.     
  338. queries = [
  339. """select * from nondrinkers""",
  340. """select drinker as x from likes
  341.    union select beer as x from serves
  342.           union select drinker as x from frequents""",
  343. """select f.drinker, s.bar, l.beer
  344.    from frequents f, serves s, likes l
  345.    where f.drinker=l.drinker and s.beer=l.beer and s.bar=f.bar""",
  346. """select * from
  347.    likes where beer in ('bud', 'pabst')""",
  348. """select l.beer, l.drinker, count(distinct s.bar)
  349.    from likes l, serves s
  350.    where l.beer=s.beer
  351.    group by l.beer, l.drinker
  352.    order by 3 desc""",
  353. """select l.beer, l.drinker, count(distinct s.bar) as nbars
  354.    from likes l, serves s
  355.    where l.beer=s.beer
  356.    group by l.beer, l.drinker
  357.     union distinct
  358.      select beer, drinker, 0 as nbars
  359.      from likes
  360.      where beer not in (select beer from serves)
  361.    order by 3 desc""",
  362. """select avg(perweek) from frequents""",
  363. """select * 
  364.    from frequents
  365.    where perweek <= (select avg(perweek) from frequents)""",
  366. """select * 
  367.    from serves""",
  368. """select bar, avg(quantity)
  369.    from serves
  370.    group by bar""",
  371. """select * 
  372.    from serves s1
  373.    where quantity <= (select avg(quantity) 
  374.                       from serves s2 
  375.                       where s1.bar=s2.bar)""",
  376. """select * from frequents
  377.    where perweek > (select avg(perweek) from frequents)""",
  378. """select * from frequents f1
  379.    where perweek > (
  380.    select avg(perweek) from frequents f2
  381.    where f1.drinker = f2.drinker)""",
  382. """select * from frequents
  383.    where perweek < any (select perweek from frequents)""",
  384. """select * from frequents
  385.    where perweek >= all (select perweek from frequents)""",
  386. """select * from frequents
  387.    where perweek <= all (select perweek from frequents)""",
  388. """select * from frequents f1
  389.    where perweek < any 
  390.    (select perweek from frequents f2
  391.     where f1.drinker = f2.drinker)""",
  392. """select * from frequents f1
  393.    where perweek = all 
  394.    (select perweek from frequents f2
  395.     where f1.drinker = f2.drinker)""",
  396. """select * from frequents f1
  397.    where perweek <> all
  398.    (select perweek from frequents f2
  399.     where f1.drinker <> f2.drinker)""",
  400. """select beer
  401.    from serves
  402.    where beer = any (select beer from likes)""",
  403. """select beer
  404.    from serves
  405.    where beer <> all (select beer from likes)""",
  406. """select beer
  407.    from serves
  408.    where beer in (select beer from likes)""",
  409. """select beer
  410.    from serves
  411.    where beer not in (select beer from likes)""",
  412. #"""select f1.drinker, f2.drinker
  413. #   from frequents f1, frequents f2
  414. #   where f1.drinker<>f2.drinker""",
  415. #"""select *
  416. #   from frequents f1
  417. #   where not exists
  418. #   (select f2.drinker
  419. #    from frequents f2
  420. #    where f1.drinker<>f2.drinker and f1.bar=f2.bar)""",
  421. """select *
  422.    from frequents
  423.    where perweek between 2 and 
  424.         (select avg(perweek) from frequents)""",
  425. """select *
  426.    from frequents
  427.    where perweek not between 2 and 5""",
  428. #   "stop",
  429. """select f.drinker, l.beer, s.bar
  430.    from frequents f, serves s, likes l
  431.    where f.drinker=l.drinker and s.bar=f.bar and s.beer=l.beer""",
  432.    #"stop!",
  433. """select * from serves""",
  434. """select * from likes""",
  435. """select * from frequents
  436.    where drinker = 'norm'""",
  437. """select drinker from likes
  438.    union
  439.    select drinker from frequents""",
  440. """select drinker from likes
  441.    union distinct
  442.    select drinker from frequents""",
  443. """select drinker from likes
  444.    except
  445.    select drinker from frequents""",
  446. """select drinker from likes
  447.    intersect
  448.    select drinker from frequents""",
  449. #   "stop!",
  450. """select * from frequents
  451.    where drinker>'norm'""",
  452. """select * from frequents
  453.    where drinker<='norm'""",
  454. """select * from frequents
  455.    where drinker>'norm' or drinker<'b'""",
  456. """select * from frequents
  457.    where drinker<>'norm' and 'pierre'<>drinker""",
  458. """select * from frequents
  459.    where drinker<>'norm'""",
  460. """select (drinker+' ')*2+bar
  461.    from frequents
  462.    where drinker>bar""",
  463. """select *
  464.    from frequents as f, serves as s
  465.    where f.bar = s.bar""",
  466. """select *
  467.    from frequents as f, serves as s
  468.    where f.bar = s.bar and
  469.      not exists(
  470.        select l.drinker, l.beer
  471.        from likes l
  472.        where l.drinker=f.drinker and s.beer=l.beer)""",
  473. """select *
  474.    from likes l, frequents f
  475.    where f.bar='cheers' and l.drinker=f.drinker and l.beer='bud'""",
  476. """select *
  477.    from serves s
  478.    where not exists (
  479.      select *
  480.      from likes l, frequents f
  481.      where f.bar = s.bar and f.drinker=l.drinker and s.beer=l.beer)""",
  482. """select 'nonbeer drinker '+f.drinker
  483.    from frequents f
  484.    where not exists
  485.       (select l.drinker, l.beer from likes l where l.drinker=f.drinker)""",
  486. """select l.drinker+' likes '+l.beer+' but goes to no bar'
  487.    from likes l
  488.    where not exists (select f.drinker from frequents f where f.drinker=l.drinker)""",
  489. """select bar from frequents""",
  490. """select distinct bar from frequents""",
  491. """select sum(quantity), avg(quantity), count(*), sum(quantity)/count(quantity)
  492.    from serves""",
  493. """select beer, sum(quantity), avg(quantity), count(*), sum(quantity)/count(quantity)
  494.    from serves 
  495.    group by beer""",
  496. """select sum(quantity), avg(quantity), count(*), sum(quantity)/count(quantity)
  497.    from serves
  498.    where beer<>'bud'
  499. """,
  500. """select bar, sum(quantity), avg(quantity), count(*), sum(quantity)/count(quantity)
  501.    from serves
  502.    where beer<>'bud'
  503.    group by bar
  504.    having sum(quantity)>500 or count(*)>3
  505.    order by 2 desc
  506. """,
  507. """select beer, sum(quantity), avg(quantity), count(*)
  508.    from serves
  509.    where beer<>'bud'
  510.    group by beer
  511.    having sum(quantity)>100
  512.    order by 4 desc, beer
  513. """,
  514. """select l.drinker, l.beer, count(*), sum(l.perday*f.perweek)
  515.    from likes l, frequents f
  516.    where l.drinker=f.drinker
  517.    group by l.drinker, l.beer
  518.    order by 4 desc, l.drinker, l.beer
  519. """,
  520. """select l.drinker, l.beer, f.bar, l.perday, f.perweek
  521.    from likes l, frequents f
  522.    where l.drinker=f.drinker
  523.    order by l.drinker, l.perday desc, f.perweek desc
  524. """,
  525. ]
  526.  
  527. dynamic_queries = [
  528. ( "select bar from frequents where drinker=?", ("norm",) ), 
  529. ( "select * from frequents where drinker=? or bar=?", ("norm", "cheers") )
  530. ]
  531.  
  532. updates = [
  533. """select * from frequents""",
  534. """select * from likes""",
  535. """select * from serves""",
  536. """select bar, sum(quantity), avg(quantity), count(*), sum(quantity)/count(quantity)
  537.    from serves
  538.    where beer<>'bud'
  539.    group by bar
  540.    having sum(quantity)>500 or count(*)>3
  541.    order by 2 desc
  542. """,
  543.  
  544. """select count(*), d from nondrinkers group by d""",
  545. """insert into frequents (drinker, perweek, bar)
  546.    values ('billybob', 4, 'cheers')""",
  547. """select * from nondrinkers""",
  548. """create table templikes (dr varchar, be varchar)""",
  549. """select * from templikes""",
  550. """insert into templikes(dr, be)
  551.    select drinker, beer from likes""",
  552. """create index tdindex on templikes(dr)""",
  553. """create index tbindex on templikes(be)""",
  554. """select * from templikes""",
  555. """delete from templikes where be='rollingrock' """,
  556. """select * from templikes""",
  557. """update templikes set dr=dr+'an' where dr='norm' """,
  558. """drop index tdindex""",
  559. """delete from templikes
  560.    where dr=(select min(dr) from templikes)""",
  561. """insert into templikes (dr, be) 
  562.    select max(dr), min(be) from templikes""",
  563. """select * from templikes""",
  564. """select * from frequents""",
  565. """update frequents 
  566.    set perweek=(select max(perweek) 
  567.                 from frequents
  568.                 where drinker='norm')
  569.    where drinker='woody'""",
  570. """select * from frequents""",
  571. """create view lazy as
  572.    select drinker, sum(perweek) as wasted 
  573.    from frequents
  574.    group by drinker
  575.    having sum(perweek)>4
  576.    order by drinker""",
  577. """select * from lazy""",
  578. """drop view lazy""",
  579. """drop table templikes""",
  580. ]
  581.  
  582. trace_updates = [
  583. """drop index tdindex""",
  584. ]
  585.  
  586. rollback_queries = [
  587. """select * from likes""",
  588. """select * from frequents""",
  589. """select * from nondrinkers""",
  590. """select * from alldrinkers""",
  591. """select * from dummy""",
  592. ]
  593. rollback_updates = [
  594. """create table dummy (nothing varchar)""",
  595. """insert into frequents(drinker, bar, perweek)
  596.    values ('nobody', 'nobar', 0)""",
  597. """insert into likes(drinker, beer, perday)
  598.    values ('wally', 'nobar', 0)""",
  599. """drop view alldrinkers""",
  600. ]
  601. keep_updates = [
  602. """insert into frequents(drinker, bar, perweek)
  603.    values ('peter', 'pans', 1)""",
  604. """create view alldrinkers as
  605.     select drinker from frequents
  606.     union
  607.     select drinker from likes""",
  608. ]
  609.  
  610. def rollbacktest(directory):
  611.     print "*" * 30
  612.     print "*** recovery test ***"
  613.     print; print; print
  614.     import sys
  615.     from gadfly import gadfly
  616.     print "*** connecting"
  617.     connect = gadfly("test", directory)
  618.     cursor = connect.cursor()
  619.     connect.autocheckpoint = 0
  620.     print "*** executing updates to commit"
  621.     for x in keep_updates:
  622.         print x
  623.         cursor.execute(x)
  624.     connect.verbose=1
  625.     print "*** COMMITTING OPERATIONS (connection set to verbose)"
  626.     connect.commit()
  627.     print "*** DUMP LOG"
  628.     connect.dumplog()
  629.     print; print "*** RUNNING OPS TO ROLL BACK"
  630.     preresults = []
  631.     for s in rollback_queries:
  632.         print; print; print s
  633.         try:
  634.             cursor.execute(s)
  635.             preresults.append(cursor.fetchall())
  636.             print cursor.pp()
  637.         except:
  638.             d = sys.exc_type
  639.             print "exception", d
  640.             preresults.append(d)
  641.     print; print "*** now updating with ops to rollback"
  642.     for s in rollback_updates:
  643.         print; print; print s
  644.         cursor.execute(s)
  645.     print; print; print "*** testing noncommitted results"
  646.     for dummy in (1,2):
  647.         postresults = []
  648.         for s in rollback_queries:
  649.             print s
  650.             try:
  651.                 cursor.execute(s)
  652.                 postresults.append(cursor.fetchall())
  653.                 print cursor.pp()
  654.             except:
  655.                 d = sys.exc_type
  656.                 print "*** exception", d
  657.                 postresults.append(d)
  658.         if preresults==postresults:
  659.             print "*** same results as before uncommitted updates"
  660.         else:
  661.             print "*** differing results from before uncommitted updates"
  662.         if dummy==1:
  663.             print; print "*** ROLLING BACK!"
  664.             connect.rollback()
  665.     print; print "*** EMULATING RECOVERY"
  666.     for s in rollback_updates:
  667.         print; print; print s
  668.         cursor.execute(s)
  669.     for dummy in (1,2):
  670.         postresults = []
  671.         for s in rollback_queries:
  672.             print s
  673.             try: 
  674.                 cursor.execute(s)
  675.                 postresults.append(cursor.fetchall())
  676.                 print cursor.pp()
  677.             except:
  678.                 d = sys.exc_type
  679.                 print "*** exception", d
  680.                 postresults.append(d)
  681.         if preresults==postresults:
  682.             print "*** same results as before uncommitted updates"
  683.         else:
  684.             print "*** differing results from before uncommitted updates"
  685.         if dummy==1:
  686.             print "*** RESTART: DUMPLOG"
  687.             connect.dumplog()
  688.             print "*** RESTARTING (RECOVER FROM LOG, DISCARD UNCOMMITTED)"
  689.             connect.restart()
  690.     
  691. def retest(directory): 
  692.     print "*" * 30
  693.     print "*** reconnect test"
  694.     from gadfly import gadfly
  695.     connect = gadfly("test", directory)
  696.     cursor = connect.cursor()
  697.     for s in updates:
  698.         print; print
  699.         print s
  700.         if s in trace_updates:
  701.             cursor.EVAL_DUMP = 1
  702.         cursor.execute(s)
  703.         cursor.EVAL_DUMP = 0
  704.         print cursor.pp()
  705.     #print; print "CONNECTION DATA BEFORE COMMIT"
  706.     #connect.DUMP_ALL()
  707.     connect.commit()
  708.     #print; print "CONNECTION DATA AFTER COMMIT"
  709.     #connect.DUMP_ALL()
  710.     connect.close()
  711.     return connect
  712.     
  713. if __name__=="__main__":
  714.    import sys
  715.    argv = sys.argv
  716.    if len(argv)<2:
  717.       print "USAGE: python <thismodule> <db_directory>"
  718.       print "  please provide a directory for test database!"
  719.    else:
  720.       directory = argv[1]
  721.       test(directory)
  722.       rollbacktest(directory)
  723.       retest(directory)
  724.